<?php

use App\Helpers\URL;

if ($event !== 'contactsList') { ?>
<?php $app->render('templates/dashboard_open', ['app' => $app, 'title' => 'Contactos']) ?>
<main>
  <h1>Contactos</h1>
  <p><a href="<?= URL::site('contacts/new') ?>" class="button primary">+ Agregar contacto</a></p>
<?php } ?>
  <section id="contactsList">
    <?php if (isset($success)) { ?>
      <?php $app->render('components/success', ['success' => $success]) ?>
    <?php } ?>
    <?php if (isset($error)) { ?>
      <?php $app->render('components/error', ['error' => $error]) ?>
    <?php } ?>
    <div class="row is-horizontal-align">
      <?php foreach ($contacts as $contact) { ?>
        <?php $app->render('contacts/show', ['app' => $app, 'event' => "contactShow_{$contact['id']}", 'contact' => $contact]) ?>
      <?php } ?>
    </div>
  </section>
<?php if ($event !== 'contactsList') { ?>
</main>
<?php $app->render('templates/dashboard_close', ['app' => $app]) ?>
<?php } ?>
